package cn.wp.common.core.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 判断手机号码是否合格
 */
public class PhoneUtil {
    public static boolean chackphone(String phone) {
        String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
        if (phone.length() != 11) {
            return false;
        } else {
            Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(phone);
            boolean isMatch = m.matches();
            if (isMatch) {
                return true;
            } else {
                return false;
            }
        }

    }

    public static void main(String[] args) {
        System.out.println(PhoneUtil.chackphone("15769393712"));
        System.out.println(PhoneUtil.chackphone("25769393712"));
    }
}
